package live.zs.elasticsearchdata.repository.mysql;

import live.zs.elasticsearchdata.entity.mysql.MysqlBlog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author madison
 * @description
 * @date 2021/3/4 9:33 下午
 */
public interface MysqlBlogRepository extends JpaRepository<MysqlBlog, Integer> {
    @Query("select e from MysqlBlog e order by e.createTime desc")
    List<MysqlBlog> queryAll();

    @Query("select e from MysqlBlog e " +
            "where e.title like concat('%',:keyword, '%') " +
            "or e.content like concat('%',:keyword, '%') " +
            "order by e.createTime desc")
    List<MysqlBlog> queryBlogs(@Param("keyword") String keyword);
}
